﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace UpdatedHomeMaker
{
    public partial class AddClientForm : Form
    {
        public ClientInfo newClient;
        public AddClientForm()
        {
            InitializeComponent();
            newClient = new ClientInfo();
        }
        public AddClientForm(ClientInfo toEdit)
        {
            InitializeComponent();
            newClient = new ClientInfo(toEdit);
            txtLastName.Text = newClient.LastName;
            txtMiddleName.Text = newClient.MiddleName;
            txtFirstName.Text = newClient.FirstName;
            txtUnits.Text = newClient.TotalUnits.ToString();
        }
        private void txtLastName_TextChanged(object sender, EventArgs e)
        {
            newClient.LastName = txtLastName.Text;
        }

        private void txtMiddleName_TextChanged(object sender, EventArgs e)
        {
            newClient.MiddleName = txtMiddleName.Text;
        }

        private void txtFirstName_TextChanged(object sender, EventArgs e)
        {
            newClient.FirstName = txtFirstName.Text;
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            newClient.TotalUnits = Int32.Parse(txtUnits.Text);
        }

        private void txtUnits_KeyPress(object sender, KeyPressEventArgs e)
        {
            int isNumber = 0;
            e.Handled = !int.TryParse(e.KeyChar.ToString(), out isNumber);
        }

        private void btnDone_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK; 
            this.Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void txtID_TextChanged(object sender, EventArgs e)
        {
            newClient.ID1 = txtID.Text;
        }

    }
}
